package com.atguigu.spzx.common.service.exception;

import com.atguigu.spzx.model.vo.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName: GlobaExceptionHandler
 * @Package: com.atguigu.spzx.common.service.exception
 * @Description 全局的异常处理器
 * @Author 孤妤
 * @Date: 2023/12/2 10:30
 */
@RestControllerAdvice
public class GlobaExceptionHandler {
    @ExceptionHandler(value = GuiguException.class)     // 处理自定义异常
    public Result guiguExceptionHandler(GuiguException exception) {
        exception.printStackTrace();
        return Result.build(null , exception.getCode(),exception.getMessage()) ;
    }

    @ExceptionHandler(value = Exception.class)          // 处理系统异常
    public Result systemExceptionHandler(Exception exception) {
        exception.printStackTrace();
        return Result.build(null ,444,exception.getMessage()) ;
    }
}
